package toy.keli.edic.ui.home.components

import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Card
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.dp
import toy.keli.edic.R
import toy.keli.edic.data.GlobalVal.wordViewModel
import toy.keli.edic.domain.model.WordModel
import toy.keli.edic.ui.home.homescreen.FunctionButtons
import toy.keli.edic.ui.main.components.InfoDialog
import toy.keli.edic.ui.main.extend.MText as Text

class SignData(val color:Color,val text:String)
@Composable
fun SignButton(status:Int = 0,modifier: Modifier = Modifier) {
    val onPopShow = @Composable{
        Row(
            modifier = Modifier
                .fillMaxWidth()
                .padding(32.dp),
            verticalAlignment = Alignment.CenterVertically,
            horizontalArrangement = Arrangement.SpaceBetween
        ) {
            FunctionButtons(
                viewModel = wordViewModel,
                wordState = null,
                onNextWord = {}
            )
        }
    }
    val sign = when(status){
        WordModel.STATUS_KNOW -> SignData(Color.Green,"认识")
        WordModel.STATUS_VAGUE ->  SignData(Color.Yellow,"模糊")
        WordModel.STATUS_FORGET ->  SignData(Color.Red,"忘记")
        else -> SignData(MaterialTheme.colorScheme.background,"sign")
    }
    Card(
        shape = RoundedCornerShape(8.dp),
        modifier =  Modifier.clickable{
            InfoDialog.show(onPopShow)
        }
    ) {
        Column(
            verticalArrangement = Arrangement.SpaceAround,
            horizontalAlignment = Alignment.CenterHorizontally,
            modifier = modifier
                .background(sign.color)
                .padding(8.dp)
                .size(48.dp)
        ) {
            Icon(painterResource(id = R.drawable.calendar), contentDescription = null,
                tint = MaterialTheme.colorScheme.onBackground)
            Text(
                text = sign.text,
                color = MaterialTheme.colorScheme.onBackground,
                style = MaterialTheme.typography.titleMedium
            )
        }
    }
}